#!/usr/bin/env python3
"""
检查FastAPI应用路由注册状态
"""
import sys
sys.path.append('.')

try:
    from main import app
    print("应用创建成功")
    
    # 获取所有路由
    routes = []
    for route in app.routes:
        if hasattr(route, 'path') and hasattr(route, 'methods'):
            routes.append(f"{route.methods} {route.path}")
        elif hasattr(route, 'prefix'):
            routes.append(f"Router: {route.prefix}")
        elif hasattr(route, 'path'):
            routes.append(f"Mount: {route.path}")
    
    print("\n已注册的路由:")
    for route in sorted(routes):
        print(f"  {route}")
    
    # 检查特定路由
    print("\n检查关键路由:")
    key_routes = ['/api/data-sources', '/api/llm', '/api/llm/providers']
    
    for route_path in key_routes:
        found = any(route_path in route for route in routes)
        print(f"  {route_path}: {'✓' if found else '✗'}")
        
except Exception as e:
    print(f"错误: {e}")
    import traceback
    traceback.print_exc()